﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;

namespace Jbe.TestSuite.LogViewer.Presentation
{
    internal class StringArrayToStringConverter : IValueConverter
    {
        private static readonly StringArrayToStringConverter @default = new StringArrayToStringConverter();


        public static StringArrayToStringConverter Default { get {return @default; } }


        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is IEnumerable<string>)
            {
                IEnumerable<string> strings = value as IEnumerable<string>;
                StringBuilder stringBuilder = new StringBuilder();
                foreach (string str in strings) 
                {
                    stringBuilder.Append(str);
                    stringBuilder.Append(" ");
                }
                return stringBuilder.ToString();
            }
            throw new NotSupportedException();
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
